package cn.tom.fiter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;


@WebFilter(filterName = "MyFilter",urlPatterns = "/**")
public class MyFiler implements Filter {
    public MyFiler(){
        System.out.println("MyFiler.....");
    }
    @Override
public void doFilter(ServletRequest servletRequest,
                               ServletResponse servletResponse,
                               FilterChain filterChain) throws IOException,ServletException{
             System.out.println("进入到过滤器");
//             1.session
//
             HttpServletRequest request=(HttpServletRequest) servletRequest;
             HttpSession session=request.getSession();
             String serletPath=request.getServletPath();

             System.out.println("session="+session);
             System.out.println("请求路径:"+serletPath);

//             让过滤器继续过滤，直到Servet(Count)
             filterChain.doFilter(servletRequest,servletResponse);
         }



}
